//	ID : pallab81
// 	PROG : 11110
// 	LANG : C++
// 	2011-07-06-15.25.17 Wednesday
//
// 	"I have not failed, I have just found 10000 ways that won't work.
//


#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>

using namespace std;

#define fo(i,x) for(int i = 0 ; i < x ; ++i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define pb push_back
#define mk make_pair
#define f first
#define s second

int n,num;
int grid[150][150];
char line[10100];
int vis[10100];
int mov[4][2]= {{+1,0},{-1,0},{0,+1},{0,-1} };

inline int toI(string ss){
    int d;
    sscanf(ss.c_str(),"%d",&d) ;
return d;
}
inline void print(){
    fo(i,n){
        fo(j,n){
            printf("%d\t",grid[i][j]);
        }
        printf("\n");
    }
}
inline void fillGrid(int num){
    stringstream ss( (string)line );
    vector< int > vt;
    for( string temp=""; getline(ss,temp,' ') ; ){
        if(temp=="")continue;
        vt.pb( toI(temp) );
    }
    for(int i=0; i<SZ(vt); i+=2 ){
        grid[ vt[i]-1 ][ vt[i+1]-1 ] = num ;
    }
}
inline void read(){
    scanf("\n");
    memset( grid, 0, sizeof(grid) );
    num=1;
    fo(i,n-1){
        gets(line);
        fillGrid(num);
        ++num;
    }
}
inline void fill(int i, int j, int col){
    stack< pair<int,int> > st;
    st.push( mk(i,j) );
    grid[i][j]=-1;

    while( st.empty()==false ){
        pair< int , int > peak = st.top();
        st.pop();

            fo(k,4){
                int tr = peak.f+mov[k][0];
                int tc = peak.s+mov[k][1];
                if( tr < 0 || tr >= n || tc < 0 || tc >=n )continue;
                if( grid[tr][tc]==col ){
                    grid[tr][tc]=-1;
                    st.push( mk(tr,tc) );
                }
            }

    }
}
inline void proc(){
    int i,j;
    memset(vis,-1,sizeof(vis));
    bool nice = true;
    fo(i,n){
        fo(j,n){
            int now_col = grid[i][j];
            if( now_col == -1 )continue;
            else if( vis[now_col]!=0 ){
                vis[now_col]=0;
                fill(i,j, now_col);
            }
            else{
                nice=false;
                goto L;
            }
        }
    }
    L:
        //print();
        if(!nice){
            printf("wrong\n");
        }
        else{
            printf("good\n");
        }
}

int main(){
    while( scanf("%d",&n)==1 && n!=0 ){
        read();
        proc();
    }

return 0;
}

